<template>
    <div class="quanbu">
        <div>
            <div class="header">
                <h5> 
                    修改活动菜单
                </h5>
            </div>
            <div class="big" >
                <div style="margin: 20px;"></div>
            <el-form label-width="120px" :model="shuju" >
                <el-form-item label="活动菜单名称">
                    <el-input v-model="shuju.aName"></el-input>
                </el-form-item>
                <el-form-item label="活动时间">
                    <el-input v-model="shuju.aDate"></el-input>
                </el-form-item>
                <el-form-item label="原菜单图标">
                    <el-input v-model="shuju.aImg"></el-input>
                </el-form-item>
                <el-form-item label="活动菜单图标">
                    <el-upload class="upload-demo" action="http://132.232.110.185/personnelManagement/activations/imgUploadFile"
                        :on-preview="handlePreview" :on-remove="handleRemove" :on-success="success" multiple
                        :limit="1" :on-exceed="handleExceed" :file-list="fileList">
                        <el-button size="small" type="primary">点击上传</el-button>
                        <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
                    </el-upload>
                </el-form-item>
                <el-form-item label="活动内容">
                    <el-input v-model="shuju.aDescription"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">修改菜单</el-button>
                </el-form-item>
            </el-form>
            </div>
        </div>
    </div>
</template>
<script>
import axios from 'axios'
const $host = 'http://132.232.110.185/personnelManagement'
export default {

    mounted() {
        // console.log(this.$route.params)
        this.shuju = this.$route.params.row
        console.log(this.shuju)
        // this.tName = this.$route.params.row.tName
    },
    data() {
        let shuju = {};
        return {
            fileList: [],
            shuju,
            img:''
        }
    },
    methods: {
        handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file);
      },
      handleExceed(files, fileList) {
        this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
      },
      success(res,file){
        console.log(res)
        this.img=res.data
      },
      onSubmit() {
            axios({
                method: 'post',
                url: `${$host}/activations/activationUpdate`,
                params: {
                    aId: this.shuju.aId,
                    aImg: this.img,
                    aDate: this.shuju.aDate,
                    aDescription: this.shuju.aDescription,
                    aName: this.shuju.aName
                }
            }).then(res => {
                this.$router.push({
                    path: "/activity/updateActivity"
                })
                // console.log(res)
            })
                .catch(err => {
                    console.log(err)
                })
        }
    }

}

</script>
<style scoped>
.quanbu {
    margin: 20px;
    /* border: 1px solid #cfd1d2; */
}

.header {
    width: 100%;
    height: 50px;
    padding-left: 6px;
    display: flex;
    align-items: center;
    font-size: 18px;
    border-bottom: 1px solid #cfd1d2;
}

.title {
    font-size: 10px;
}

.inpu {
    width: 80%;
    height: 50px;
   
}
.inpu4{
    width: 80%;
    height: 50px;
}

.box {
    display: flex;
    margin: 15px;
    justify-content: space-between;
}
.btn{
    
    margin-left: 600px;
    margin-top: 100px;
}
</style>